package czk.jvm.lecture.classloader;





import java.sql.Driver;
import java.util.Iterator;
import java.util.ServiceLoader;

public class MyTest26 {
    public static void main(String[] args) {
        ServiceLoader<Driver> drivers = ServiceLoader.load(Driver.class);
        //启动类加载器加载
        System.out.println(Driver.class.getClassLoader());
        Iterator<Driver> iterator = drivers.iterator();
        while (iterator.hasNext()){
            //系统类加载器来加载，在meta.service下，java sql接阔规范中规定
            Driver driver = iterator.next();
            System.out.println("driver  "+driver.getClass()+"driverClassLoader  "+driver.getClass().getClassLoader());
        }
        System.out.println("当前线程的上下文加载器"+Thread.currentThread().getContextClassLoader());
        System.out.println("ServiceLoader的类加载器"+ServiceLoader.class.getClassLoader());
    }
}
